package com.ddd.infrastructure.convertor;

import com.ddd.domain.operationLog.model.OperationLogEntity;
import com.ddd.infrastructure.repository.database.dataobject.OperationLogDo;

/**
 * OperationLogConvertor DO <---> Entity
 *
 * @author guowm
 */
public class OperationLogConvertor {
    public static OperationLogEntity toEntity(OperationLogDo operationLogDo) {
        OperationLogEntity operationLogEntity = new OperationLogEntity();
        operationLogEntity.setId(operationLogDo.getId());
        operationLogEntity.setIp(operationLogDo.getIp());
        operationLogEntity.setLocation(operationLogDo.getLocation());
        operationLogEntity.setUri(operationLogDo.getUri());
        operationLogEntity.setMethod(operationLogDo.getMethod());
        operationLogEntity.setWasteTime(operationLogDo.getWasteTime());
        operationLogEntity.setRequestParam(operationLogDo.getRequestParam());
        operationLogEntity.setRequestBody(operationLogDo.getRequestBody());
        operationLogEntity.setResponseResult(operationLogDo.getResponseResult());

        return operationLogEntity;
    }

    public static OperationLogDo toAddOperationLogDo(OperationLogEntity operationLogEntity) {
        OperationLogDo operationLogDo = new OperationLogDo();
        operationLogDo.setIp(operationLogEntity.getIp());
        operationLogDo.setLocation(operationLogEntity.getLocation());
        operationLogDo.setUri(operationLogEntity.getUri());
        operationLogDo.setMethod(operationLogEntity.getMethod());
        operationLogDo.setWasteTime(operationLogEntity.getWasteTime());
        operationLogDo.setRequestParam(operationLogEntity.getRequestParam());
        operationLogDo.setRequestBody(operationLogEntity.getRequestBody());
        operationLogDo.setResponseResult(operationLogEntity.getResponseResult());

        return operationLogDo;
    }
}
